<?php

if( !defined( 'MEDIAWIKI' ) )
die(-1);


require_once('DatabaseFunctions.php');

#install extension hook
$wgHooks['CategoryPageView'][] = "wfCategoryCache";

function wfCategoryCache(){
  global $wgTitle, $wgDBprefix, $wgOut, $wgCategory, $wgMemc,$wgCorrespondence;
  if ($wgTitle->mNamespace==NS_CATEGORY) //checl the memcached
  {
     $cat = normalize($wgTitle->mTextform);
      $wgCategory = 0;
      if ($cat!=='all'){
			$cat = crcGenre($cat);
			$wgCategory = $cat+4294967296;
			
			foreach ($wgCorrespondence as $key => $value){
				if ($value==$cat){
					$wgCategory.=",".($key+4294967296);
				}
			}

     }
  }
  return true;
}
